// components/like/like.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    like: {
      type: Boolean,
      value: true
    },
    //  observer:function(){}
    count: {
      type: String,
      // value:99
    }

  },

  /**
   * 组件的初始数据
   */
  data: {
    yesSrc: '../../images/love.png',
    noSrc: '../../images/love_empty.png'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onLike:function(){
      let like = this.properties.like
      let count = parseInt(this.properties.count)
      console.log(count)
      count = like ? count - 1 : count + 1
      this.setData({
        count: count,
        like: !like
      })

      let havrGive = this.properties.like ? 'yesGive' : 'noGive'

      // 向父组件传参 
      this.triggerEvent("like", {
        havrGive: havrGive
      }, {})


    }
  }



})